<?php
/*
Uploadify v3.0.0
Copyright (c) 2010 Ronnie Garcia

Return true if the file exists
*/
//file_put_contents('/home/vhosts/steel/www/x/uploadify/test.txt', $_SERVER['DOCUMENT_ROOT'] . '/x/media/' . $_POST['filename']);
$photoExtensions = array('jpg', 'jpeg', 'gif', 'png');
$videoExtensions = array('flv', 'f4v', 'f4p', 'f4a', 'f4b', 'aac');

$fileName = $_POST['filename'];
$fileNameWithoutExtension = substr($fileName, 0, strrpos($fileName, '.'));
$extension = substr($fileName, strrpos($fileName, '.') + 1);

if(in_array($extension, $photoExtensions)) {
	if (file_exists($_SERVER['DOCUMENT_ROOT'] . '/x/media/' . $fileNameWithoutExtension . '_real.' . $extension) ||
		file_exists($_SERVER['DOCUMENT_ROOT'] . '/x/media/' . $fileNameWithoutExtension . '_thumbnail.' . $extension)) {	
		echo 1;
	} else {
		echo 0;
	}	
} else if(in_array($extension, $videoExtensions)) {
	if (file_exists($_SERVER['DOCUMENT_ROOT'] . '/x/media/' . $fileName)) {	
		echo 1;
	} else {
		echo 0;
	}
}
?>